package com.ws.util;

public class Result {

    //接口调用返回结果的状态码，一般会仿照http请求的常用状态码来告诉前端接口调用的情况
    private int code;

    //接口返回数据的具体内容，他是任意类型的数据，因为他可能是字符串，可能是数组，可能是对象，也可能是json结构
    private Object data;

    //接口返回的业务的语言描述，可能是汉字也可能是英文
    private String msg;

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    private static Result result;

    public static Result getResult() {
        return result;
    }

    public static void setResult(Result result) {
        Result.result = result;
    }

    public Result(int code, Object data, String msg) {
        this.code = code;
        this.data = data;
        this.msg = msg;
    }

    public static Result end(int code,Object data,String msg){
      //  System.out.println(result);
        if(result == null){
            return new Result(code,data,msg);
        }else{
            result.code = code;
            result.data = data;
            result.msg = msg;
            return result;
        }
    }

}
